package com.tencent.sr.iris.basic.saas.service.group;

import com.alibaba.fastjson.JSON;
import com.tencent.sr.iris.activity.interfaces.request.group.AdvisorGroupTaskRequest;
import com.tencent.sr.iris.activity.interfaces.request.group.AdvisorGroupTaskSecondRequest;
import com.tencent.sr.iris.activity.interfaces.request.group.AdvisorGroupTaskThirdRequest;
import com.tencent.sr.iris.activity.interfaces.request.group.GroupTaskRequest;
import com.tencent.sr.iris.activity.interfaces.request.group.GroupTaskSecondRequest;
import com.tencent.sr.iris.basic.saas.common.enums.YesOrNoEnum;
import com.tencent.sr.iris.basic.saas.service.export.ExportService;
import com.tencent.sr.iris.basic.saas.interfaces.response.export.ExportResponse;
import com.tencent.sr.rmall.material.interfaces.enums.ETaskBusinessType;
import com.tencent.sr.rmall.springbootstarter.authtoken.localbean.AppUser;

import java.util.Objects;
import javax.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
@Slf4j
public class ExportTaskService {

    @Resource
    private AppUser appUser;

    @Autowired
    private ExportService exportService;

    /**
     * 团长任务列表导出
     *
     * @param request
     * @return
     */
    public ExportResponse groupTaskBoard(GroupTaskRequest request) {
        log.info("export-groupTaskBoard {}", JSON.toJSONString(request));
        return exportService.commonRequest(ETaskBusinessType.IRIS_GROUP_BOARD, request);
    }

    /**
     * 团长任务列表(邀新有礼)导出
     *
     * @param request
     * @return
     */
    public ExportResponse groupTaskBoardInvite(GroupTaskSecondRequest request) {
        return exportService.commonRequest(ETaskBusinessType.IRIS_GROUP_INVITE_BOARD, request);
    }
    /**
     * 团长任务列表(首单任务)导出
     *
     * @param request
     * @return
     */
    public ExportResponse groupTaskBoardFirstOrder(GroupTaskSecondRequest request) {
        return exportService.commonRequest(ETaskBusinessType.IRIS_GROUP_FIRST_ORDER_BOARD, request);
    }

    /**
     * 团长任务列表(GMV冲刺赛/销量冲刺赛)导出
     *
     * @param request
     * @return
     */
    public ExportResponse groupTaskBoardSprint(GroupTaskSecondRequest request) {
        return exportService.commonRequest(ETaskBusinessType.IRIS_GROUP_SPRINT_BOARD, request);
    }

    /**
     * 团长任务列表(排行榜)导出
     * @param request
     * @return
     */
    public ExportResponse groupTaskRank(GroupTaskSecondRequest request) {
        return exportService.commonRequest(ETaskBusinessType.IRIS_GROUP_RANK, request);
    }

    /**
     * 导师--团长任务列表导出
     *
     * @param request
     * @return
     */
    public ExportResponse advisorGroupTaskBoard(AdvisorGroupTaskRequest request) {
        if (Objects.equals(request.getIsAdviser(), YesOrNoEnum.YES.getValue())) {
            request.setAdviserId(appUser.getUid());
        }
        return exportService.commonRequest(ETaskBusinessType.IRIS_ADVISOR_BOARD, request);
    }

    /**
     * 导师--团长任务列表(邀新有礼)导出
     *
     * @param request
     * @return
     */
    public ExportResponse advisorInviteBoard(AdvisorGroupTaskSecondRequest request) {
        if (Objects.equals(request.getIsAdviser(), YesOrNoEnum.YES.getValue())) {
            request.setAdviserId(appUser.getUid());
        }
        return exportService.commonRequest(ETaskBusinessType.IRIS_ADVISOR_INVITE_BOARD, request);
    }

    /**
     * 导师--团长任务列表(首单任务)导出
     *
     * @param request
     * @return
     */
    public ExportResponse advisorFirstOrderBoard(AdvisorGroupTaskSecondRequest request) {
        if (Objects.equals(request.getIsAdviser(), YesOrNoEnum.YES.getValue())) {
            request.setAdviserId(appUser.getUid());
        }
        return exportService.commonRequest(ETaskBusinessType.IRIS_ADVISOR_FIRST_ORDER_BOARD, request);
    }

    /**
     * 导师--团长任务列表(GMV冲刺赛/销量冲刺赛)导出
     *
     * @param request
     * @return
     */
    public ExportResponse advisorSprintBoard(AdvisorGroupTaskSecondRequest request) {
        if (Objects.equals(request.getIsAdviser(), YesOrNoEnum.YES.getValue())) {
            request.setAdviserId(appUser.getUid());
        }
        return exportService.commonRequest(ETaskBusinessType.IRIS_ADVISOR_SPRINT_BOARD, request);
    }

    /**
     * 导师--团长任务列表(佣金回滚任务)导出
     *
     * @param request
     * @return
     */
    public ExportResponse advisorCommissionBoard(AdvisorGroupTaskSecondRequest request) {
        if (Objects.equals(request.getIsAdviser(), YesOrNoEnum.YES.getValue())) {
            request.setAdviserId(appUser.getUid());
        }
        return exportService.commonRequest(ETaskBusinessType.IRIS_ADVISOR_COMMISSION_BOARD, request);
    }

    /**
     * 导师--三级页面团长任务列表(邀新有礼)导出
     *
     * @param request
     * @return
     */
    public ExportResponse advisorInviteThirdBoard(AdvisorGroupTaskThirdRequest request) {
        return exportService.commonRequest(ETaskBusinessType.IRIS_ADVISOR_INVITE_THIRD_BOARD, request);
    }

    /**
     * 导师--三级页面团长任务列表(首单任务)导出
     *
     * @param request
     * @return
     */
    public ExportResponse advisorFirstOrderThirdBoard(AdvisorGroupTaskThirdRequest request) {
        return exportService.commonRequest(ETaskBusinessType.IRIS_ADVISOR_FIRST_ORDER_THIRD_BOARD, request);
    }

    /**
     * 导师--三级页面团长任务列表(GMV冲刺赛/销量冲刺赛)导出
     *
     * @param request
     * @return
     */
    public ExportResponse advisorSprintThirdBoard(AdvisorGroupTaskThirdRequest request) {
        return exportService.commonRequest(ETaskBusinessType.IRIS_ADVISOR_SPRINT_THIRD_BOARD, request);
    }

    /**
     * 导师--三级页面团长任务列表(佣金回滚任务)导出
     *
     * @param request
     * @return
     */
    public ExportResponse advisorCommissionThirdBoard(AdvisorGroupTaskThirdRequest request) {
        return exportService.commonRequest(ETaskBusinessType.IRIS_ADVISOR_COMMISSION_THIRD_BOARD, request);
    }

    /**
     * 团长--二级页面（普通团推团）
     * @param request
     * @return
     */
    public ExportResponse groupNormalBoard(GroupTaskSecondRequest request) {
        return exportService.commonRequest(ETaskBusinessType.IRIS_GROUP_NORMAL_INVITE, request);
    }

    /**
     *团长--二级页面（特邀团推团）
     * @param request
     * @return
     */
    public ExportResponse groupSpecialBoard(GroupTaskSecondRequest request) {
        return exportService.commonRequest(ETaskBusinessType.IRIS_GROUP_SPECIAL_INVITE, request);
    }

    /**
     *导师--二级页面（普通团推团）
     * @param request
     * @return
     */
    public ExportResponse advisorNormalBoard(AdvisorGroupTaskSecondRequest request) {
        if (Objects.equals(request.getIsAdviser(), YesOrNoEnum.YES.getValue())) {
            request.setAdviserId(appUser.getUid());
        }
        return exportService.commonRequest(ETaskBusinessType.IRIS_ADVISOR_NORMAL_INVITE, request);
    }

    /**
     *导师--二级页面（特邀团推团）
     * @param request
     * @return
     */
    public ExportResponse advisorSpecialBoard(AdvisorGroupTaskSecondRequest request) {
        if (Objects.equals(request.getIsAdviser(), YesOrNoEnum.YES.getValue())) {
            request.setAdviserId(appUser.getUid());
        }
        return exportService.commonRequest(ETaskBusinessType.IRIS_ADVISOR_SPECIAL_INVITE, request);
    }

    /**
     *导师--三级页面（普通团推团）
     * @param request
     * @return
     */
    public ExportResponse advisorNormalBoardThird(AdvisorGroupTaskThirdRequest request) {
        return exportService.commonRequest(ETaskBusinessType.IRIS_ADVISOR_NORMAL_INVITE_THIRD, request);
    }

    /**
     *导师--三级页面（特邀团推团）
     * @param request
     * @return
     */
    public ExportResponse advisorSpecialBoardThird(AdvisorGroupTaskThirdRequest request) {
        return exportService.commonRequest(ETaskBusinessType.IRIS_ADVISOR_SPECIAL_INVITE_THIRD, request);
    }

    /**
     * 导师-二级页(排行榜)
     * @param request
     * @return
     */
    public ExportResponse advisorRankBoard(AdvisorGroupTaskSecondRequest request) {
        return exportService.commonRequest(ETaskBusinessType.IRIS_ADVISOR_RANK, request);
    }

    /**
     * 导师-三级页(排行榜)
     * @param request
     * @return
     */
    public ExportResponse advisorRankBoardThird(AdvisorGroupTaskThirdRequest request) {
        return exportService.commonRequest(ETaskBusinessType.IRIS_ADVISOR_RANK_THIRD, request);
    }

    /**
     *团长--二级页面（特邀会员冲刺赛）
     * @param request
     * @return
     */
    public ExportResponse groupSpecialSprintBoard(GroupTaskSecondRequest request) {
        return exportService.commonRequest(ETaskBusinessType.IRIS_GROUP_SPECIAL_SPRINT, request);
    }

    /**
     * 导师-二级页(特邀会员冲刺赛)
     * @param request
     * @return
     */
    public ExportResponse advisorSpecialSprintBoard(AdvisorGroupTaskSecondRequest request) {
        return exportService.commonRequest(ETaskBusinessType.IRIS_ADVISOR_SPECIAL_SPRINT, request);
    }

    /**
     * 导师-三级页(特邀会员冲刺赛)
     * @param request
     * @return
     */
    public ExportResponse advisorSpecialSprintBoardThird(AdvisorGroupTaskThirdRequest request) {
        return exportService.commonRequest(ETaskBusinessType.IRIS_ADVISOR_SPECIAL_SPRINT_THIRD, request);
    }
}
